//
//  NavigationBarView.swift
//  GreenDeal
//
//  Created by Moennig Q on 2023/4/17.
//

import UIKit
import SnapKit

class ServiceBaseView: UIView {
    let topBackView = UIView()
    let backToPreBtn = UIButton()
    let refreshBtn = UIButton()
    let titleLabel = ContentLabel(R.font.interSemiBold(size: 17))
    override init(frame: CGRect) {
        super.init(frame: frame)
        self.initCommonView()
        self.setUpviews()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    private func initCommonView(){
        self.backgroundColor = .white
        //
        self.addSubview(topBackView)
        topBackView.snp.makeConstraints { make in
            make.top.equalTo(self.safeAreaLayoutGuide.snp.top)
            make.left.right.equalToSuperview()
            make.height.greaterThanOrEqualTo(0)
        }
        //titleLabel
        titleLabel.numberOfLines = 0
        titleLabel.textAlignment = .center
        topBackView.addSubview(titleLabel)
        titleLabel.snp.makeConstraints { make in
            make.top.equalTo(10)
            make.left.equalTo(48)
            make.right.equalTo(-48)
            make.height.greaterThanOrEqualTo(40)
            make.bottom.equalTo(-10)
        }
        //backToPreBtn
        backToPreBtn.setImage(R.image.service_navigationbar_back_icon(), for: UIControl.State.normal)
        topBackView.addSubview(backToPreBtn)
        backToPreBtn.snp.makeConstraints { make in
            make.left.equalTo(16)
            make.width.height.equalTo(40)
            make.centerY.equalTo(titleLabel)
        }
        //
        refreshBtn.setImage(R.image.installation_list_refresh_btn(), for: UIControl.State.normal)
        topBackView.addSubview(refreshBtn)
        refreshBtn.snp.makeConstraints { make in
            make.right.equalTo(-8)
            make.width.height.equalTo(40)
            make.centerY.equalTo(backToPreBtn)
        }
    }
    func setUpviews(){
        
    }
    func setTitle(_ title: String){
        self.titleLabel.text = title
    }
}
